// 柯里化案例

// ''.match(/\s+/g)
// ''.match(/\d+/g)

const _ = require('lodash')



const match =  _.curry(function (reg, str) { 
  return str.match(reg)
})

const havaSpace = match(/\s+/g)
const havaNum = match(/\d+/g)


// const filter = _.curry(function (fn, array) { 
//   return array.filter(fn)
// })

// es6
const filter = _.curry((fn, array) => array.filter(fn))

const findSpace = filter(havaSpace)

console.log(havaSpace('hello world')) // [ ' ' ]
console.log(havaNum('123 world')) // [ '123' ]



console.log(filter(havaSpace, ['123', '132 23', '22'])) // [ '132 23' ]


console.log(findSpace(['123', '132 23', '22'])); // [ '132 23' ]

